package beanAction;
import java.util.ArrayList;

import com.opensymphony.xwork2.ActionSupport;

import model.*;
public class AuthentificationAction extends ActionSupport {
	private static final long serialVersionUID = 1L;
	
	protected final String NOTLOGGED = "notlogged";
	
	private String loginUser;
	private String mdpUser;
	private boolean identificationUtilisateur;
	
	private ArrayList<String> statutList;
	private  String statut;
	
	public ArrayList<String> getStatutList() {
		return statutList;
	}
	public void setStatutList(ArrayList<String> statutList) {
		this.statutList = statutList;
	}
	
	
	public String getLoginUser() {
		return loginUser;
	}
	public void setLoginUser(String loginUser) {
		this.loginUser = loginUser;
	}
	public String getMdpUser() {
		return mdpUser;
	}
	public void setMdpUser(String mdpUser) {
		this.mdpUser = mdpUser;
	}
	
	 private boolean isInvalid(String value) {
	        return (value == null || value.length() == 0);
	    }
	

		public String populate() {
			
		       statutList = new ArrayList<String>();
		       statutList.add("Frai direct");
		       statutList.add("ouvrier");
		       statutList.add("chef d'equipe");
		       System.out.println("uuuuuuuuuuuuuuuuuuu");
		       return "sslect";
		
		
	}	
	

		public String Sconnecter() {
			
			String login=this.getLoginUser();
			String mdpass=this.getMdpUser();
			AuthentifModel authMdl=new AuthentifModel();
			identificationUtilisateur=authMdl.isIdentifier(login,mdpass);
			
			if (isInvalid(login)) return "input";

		    else  
			   {if (isInvalid(mdpass)) return "input";
		        else 
		            if(identificationUtilisateur!=true)
			//if(!getLoginUser().equalsIgnoreCase(""))
						{
				        addActionMessage("attention :vous avez fait erreur dans le login ou le mot de passe ");
				         return "error";
				        }
		            else return "success";
		            
			   }
			
			
			
			 
		}
	

}
